class Stack {
  constructor() {
    this.items = []
  }
  // 入栈
  push(element) {
    this.items.push(element)
  }
  // 出栈
  pop(element) {
    this.items.pop()
  }
  // 判空
  isEmpty() {
    return this.items.length === 0
  }
  // 清空
  clear() {
    this.items = []
  }
  // 查看
  peek() {
    if (this.isEmpty()) {
      return undefined
    }
    return this.items[this.size() - 1]
  }
  // 大小
  size() {
    return this.items.length
  }
  // 转数组
  toArray() {
    return this.items
  }
  // 转字符串
  toString() {
    return this.items.toString()
  }
}
const log = console.log.bind(console)
let stack = new Stack()
stack.push('李龙生')
stack.push('张三')
stack.push('李四')
log(stack)
let stackStr = stack.toString()
log('stackStr', stackStr)
let stackEle = stack.peek()
log('stackEle', stackEle)
